﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using DBUtility;
using IDAL.RF.ProductCategory;
using Model.RF.ProductCategory;

namespace DAL.RF.ProductCategory
{
    public class ProductType_MultiBand : BaseRepository<ProductType_MultiBandInfo>, IProductType_MultiBand
    {
        #region 静态变量部分
        private const string PARM_ID = "@ID";
        private const string PARM_PRODUCTTYPEID = "@ProductTypeID";
        private const string PARM_STEPITEM = "@StepItem";
        private const string PARM_TESTBAND = "@TestBand";
        #endregion

        #region 数据检索部分
        public IList<ProductType_MultiBandInfo> LoadEntities()
        {
            return ExcuteSqlToGetEntities("ProductType_MultiBand_select");
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public ProductType_MultiBandInfo LoadEntity<T1>(T1 id)
        {
            SqlParameter parm = GetParameter();
            //Bind the parameter
            parm.Value = id;
            return ExcuteSqlToGetEntity("ProductType_MultiBand_selectbyID", parm);
        }

        public IList<ProductType_MultiBandInfo> ProductType_MultiBand_GetbyPID(string productTypeID)
        {
            SqlParameter parm = new SqlParameter(PARM_PRODUCTTYPEID, SqlDbType.NVarChar, 50);
            //Bind the parameter
            parm.Value = productTypeID;
            return ExcuteSqlToGetEntities("ProductType_MultiBand_selectbyPID", parm);
        }
        #endregion

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override ProductType_MultiBandInfo GetEntityRecord(SqlDataReader rdr)
        {
            ProductType_MultiBandInfo pro = new ProductType_MultiBandInfo()
            {
                ID = rdr.GetInt32(0),
                ProductTypeID = rdr.GetValue(1).ToString(),
                ProductTypeName = rdr.GetValue(2).ToString(),
                StepItem = rdr.GetValue(3).ToString(),
                TestBand = rdr.GetValue(4).ToString()
            };
            return pro;
        }

        public override ProductType_MultiBandInfo GetEntityRecord()
        {
            ProductType_MultiBandInfo pro = new ProductType_MultiBandInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "ProductType_MultiBand_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return "ProductType_MultiBand_Delete";
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_ID, SqlDbType.Int, 4);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_ID, SqlDbType.Int, 4),
					new SqlParameter(PARM_PRODUCTTYPEID, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_STEPITEM, SqlDbType.NVarChar, 20),
					new SqlParameter(PARM_TESTBAND, SqlDbType.NVarChar, 20)
                };
            return parms;
        }

        public override void SetParameters(ProductType_MultiBandInfo productType, params SqlParameter[] Parms)
        {
            Parms[0].Value = productType.ID;
            Parms[1].Value = productType.ProductTypeID;
            Parms[2].Value = productType.StepItem;
            Parms[3].Value = productType.TestBand;
        }
        #endregion
    }
}
